package com.jvm.d2;

/**
 * 描述:
 * -verbose:class
 * @author luzhongfu
 * Created by lucky on 2019-10-11 2:43 PM
 */
public class Singleton2 {
    private Singleton2() {}
    private static class LazyHolder {
        static final Singleton2 INSTANCE = new Singleton2();
        static {
            System.out.println("LazyHolder.<clinit>");
        }
    }
    public static Object getInstance(boolean flag) {
        if (flag) return new Singleton2.LazyHolder[2];
        return Singleton2.LazyHolder.INSTANCE;
    }
    public static void main(String[] args) {
        getInstance(true);
        System.out.println("----");
        getInstance(false);
    }
}


